﻿<input type="checkbox" class="sizes" value="S"/> S
<br/>
<input type="checkbox" class="sizes" value="M"/> M
<br/>
<input type="checkbox" class="sizes" value="L"/> L
<br/>
<input type="hidden" name="size" id="size" value=""/>
<script type="text/javascript">
    $('.sizes').change(function () {
        var values = new Array();
        $('.sizes:checked').each(function() {
            values.push($(this).val());
        });
        var value = '';
        for (var i = 0; i < values.length - 1; i++) {
            value += values[i] + ' | ';
        }
        value += values[values.length - 1];
        $('#size').val(value);
    })
</script>